package wang.API;

import java.util.ArrayList;
import java.util.Scanner;

//用于对菜品的上架和展示操作
public class FoodOperator {
    ArrayList<Food> foodlist = new ArrayList();
    //菜品上架方法
    public void addfood(){
        Food f = new Food();
        Scanner sc = new Scanner(System.in);
        System.out.println("请您输入菜品名称");
        f.setName(sc.next());
        System.out.println("请您输入菜品价格");
        f.setPrice(sc.nextDouble());
        System.out.println("请您输入菜品描述");
        f.setDesc(sc.next());
        foodlist.add(f);
        System.out.println("添加成功!");
    }
    //展示菜品方法
    public void showfoodlist(){
        if (foodlist.isEmpty()){
            System.out.println("您还没有添加菜品");
            return;
        }
        for (int i = 0; i < foodlist.size(); i++) {
           Food f = foodlist.get(i);
            System.out.println("菜品名称：");
            System.out.println(f.getName());
            System.out.println("菜品价格：");
            System.out.println(f.getPrice());
            System.out.println("菜品描述：");
            System.out.println(f.getDesc());
            System.out.println("-----------");
        }
    }
    //设计一个开始方法
    public void OperatorStart(){
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您想选择的功能");
            System.out.println("1.添加菜品");
            System.out.println("2.展示菜品");
            System.out.println("3.退出");
            String command = sc.next();
            switch (command){
                case "1":
                    addfood();
                    break;
                case "2":
                    showfoodlist();
                    break;
                case "3":
                    System.out.println("感谢使用 再见！");
                    return;
            }
        }
    }

}
